<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<title>ForgetPassword-ProjectManagment</title>
	<meta content='width=device-width, initial-scale=1.0, shrink-to-fit=no' name='viewport' />
	<link rel="icon" th:href="@{/assets/img/icon.ico}" type="image/x-icon"/>
	<div th:replace="commom/bar :: commom_css"></div>
</head>
<body class="login">
	<div class="wrapper wrapper-login">
		<div class="container container-login animated fadeIn">
			<h3 class="text-center">忘记密码</h3>
			<div class="login-form">
				<form th:action="@{/forget_password}"method="get" onSubmit="return forgetPasswordCheck();">
					<div class="form-group form-floating-label">
						<input id="email" name="email" type="email" class="form-control input-border-bottom"  autocomplete="off" required>
						<label for="email" class="placeholder">邮箱</label>
					</div>
					<div class="form-group form-floating-label">
						<input type="text" name="captchaCode" id="captchaCode"  class="form-control input-border-bottom" autocomplete="off" required>
						<label for="captchaCode" class="placeholder">验证码</label>
						<img th:src="@{/kaptcha}" id="kaptcha" width="110px" height="40px"><br>
					</div>
					<div class="row form-sub m-0">
						<div class="custom-control custom-checkbox">
							<input type="checkbox" class="custom-control-input" name="agree" id="agree">
							<label class="custom-control-label" for="agree">我同意身份验证条款</label>
						</div>
					</div>
					<div class="form-action mb-3">
						<button class="btn btn-primary btn-rounded btn-login" type="button" onclick="forgetpassword()">邮箱验证</button>
					</div>
				</form>

			</div>
		</div>
	</div>
	<script th:src="@{/assets/js/core/jquery.3.2.1.min.js}"></script>
	<script th:src="@{/assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js}"></script>
	<script th:src="@{/assets/js/core/popper.min.js}"></script>
	<script th:src="@{/assets/js/core/bootstrap.min.js}"></script>
	<script th:src="@{/assets/js/ready.js}"></script>
	<script th:inline="javascript">
		window.onload = function (ev) {
			var kaptchaImg = document.getElementById("kaptcha");
			kaptchaImg.onclick = function (ev1) {
				kaptchaImg.src = "/kaptcha?" + Math.floor(Math.random() * 100);
			}
		};
		//登录按钮事件
		function forgetpassword() {
			var email = $("#email").val();
			var captchaCode = $("#captchaCode").val();
			if (email === ""){
				return;
			}
			$.ajax({
				type: "get",
				url: "/forget_password",
				data: {
					"email": email,
					"captchaCode": captchaCode,
				},
				success: function (json) {
					if (json.ok) {
						alert(json.message)
						location.href = json.data;
					} else {
						alert(json.message);
					}
				},
			})
		};

		//检查忘记密码页面是否填写完成
		function forgetPasswordCheck() {
			if(checkemail()==false){
				return false;
			}
			if($("#agree").is(":checked")==false){
				return false;
			}
		}


	</script>
</body>
</html>